import http from '/@/serve/index';
import { formatQuery } from '/@/libs/utils/format';

/**
 * 获取流感类型鉴定桑基图
 * @param taskId 任务id
 * @param barcodeId
 * @param threshold value最小值
 * @returns
 */
export const getSankey = (taskId: string, barcodeId: string, threshold?: number) =>
  http.get(
    `/flu/tasks/${taskId}/results/${barcodeId}/type-identification/sankey?${formatQuery({
      threshold,
    })}`,
  );

/**
 * 获取流感类型鉴定桑基图
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getCategory = (taskId: string, barcodeId: string) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/type-identification/category`);

/**
 * 获取基因溯源列表
 * @param taskId 任务id
 * @param barcodeId
 * @param type na / ha
 * @returns
 */
export const getIdentity = (taskId: string, barcodeId: string, type: string) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/identity/${type}`);

/**
 * 获取变异信息列表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getMutationInfo = (taskId: string, barcodeId: string) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/mutation-info`);

/**
 * 获取基因组序列列表
 * @param taskId 任务id
 * @param barcodeId
 * @param selection 选中的基因组序列
 * @param width 文本宽度
 * @returns
 */
export const getMedaka = (taskId: string, barcodeId: string, selection: string, width: number) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/medaka?${formatQuery({ selection, width })}`);

/**
 * 获取基因组序列可选列表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getMedakaAvailableSeq = (taskId: string, barcodeId: string) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/medaka/availableSeqs`);

/**
 * 获取基因组覆盖度汇总列表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getCoverageSummary = (taskId: string, barcodeId: string) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/coverage-summary`);

/**
 * 获取基因组覆盖度图
 * @param taskId 任务id
 * @param barcodeId
 * @param selection 选中序列
 * @returns
 */
export const getCoverChart = (taskId: string, barcodeId: string, selection?: string) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/bedcov?${formatQuery({ selection })}`);

/**
 * 获取基因组覆盖度可选序列表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getCoverAvailableSeq = (taskId: string, barcodeId: string) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/bedcov/availableSeqs`);

/**
 * 获取数据统计列表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getNanoStats = (taskId: string, barcodeId: string) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/nano-stats`);

/**
 * 获取数据统计列表
 * @param taskId 任务id
 * @param barcodeId
 * @returns
 */
export const getFilteredNanoStats = (taskId: string, barcodeId: string) =>
  http.get(`/flu/tasks/${taskId}/results/${barcodeId}/filtered-nano-stat`);
